<template>
	<view class="content">

		<view class="padding bg-white text-center">
			<view class="padding margin-top" :class="size?'solids-bottom':'solid-bottom'">
				<view class="feedback-body">
					<textarea placeholder="这一刻的想法..." v-model="sendDate.content" class="feedback-textare" />
					</view>
				<view class="cu-form-group">
					<view class="grid col-4 grid-square flex-sub">
						<view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
							<image :src="imgList[index]" mode="aspectFill"></image>
							<view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
								<text class='cuIcon-close'></text>
							</view>
						</view>
						<view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
							<text class='cuIcon-cameraadd'></text>
						</view>
					</view>
				</view>
			</view>
		</view>
		    <navigator url="tabbar-3" hover-class="navigator-hover">
		    	<view class="center-list-item">
		  		<button type="primary" class="feedback-submit" @tap="send">提交</button>
		    	</view>
		    </navigator>

		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgList: [],
				size: false,
				sendDate: {
				    score: 0,
				    content: "",
				    contact: ""
				},
						
			}
		},
		onLoad() {

		},
		methods: {
			ChooseImage() {
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						if (this.imgList.length != 0) {
							this.imgList = this.imgList.concat(res.tempFilePaths)
						} else {
							this.imgList = res.tempFilePaths
						}
					}
				});
			},
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '召唤师',
					content: '确定要删除这段回忆吗？',
					cancelText: '再看看',
					confirmText: '再见',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			},
			send() { //发送反馈
			    uni.showToast({
			        title: "发布成功!"
			    });
			    this.imageList = [];
			    this.sendDate = {
			        score: 0,
			        content: "",
			        contact: ""
			    },
				uni.navigateTo({
						url: url
				});
				setTimeout(()=>{
					uni.switchTab({
						url: '/pages/user/index'
					});
				},1500);
				
			}
		}
	}
</script>

<style>
	.content {
		text-align: center;
	}
	/*问题反馈*/
	.feedback-title {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 20upx;
		color: #8f8f94;
		font-size: 28upx;
	}
	.feedback-star-view.feedback-title {
		justify-content: flex-start;
		margin: 0;
	}
	.feedback-quick {
		position: relative;
		padding-right: 40upx;
	}
	.feedback-quick:after {
		font-family: uniicons;
		font-size: 40upx;
		content: '\e581';
		position: absolute;
		right: 0;
		top: 50%;
		color: #bbb;
		-webkit-transform: translateY(-50%);
		transform: translateY(-50%);
	}
	.feedback-body {
		background: #fff;
	}
	.feedback-textare {
		height: 200upx;
		font-size: 34upx;
		text-align: left;
		line-height: 50upx;
		width: 100%;
		box-sizing: border-box;
		padding: 20upx 30upx 0;
		background-color: #FFFFFF;
	}
	.feedback-input {
		font-size: 34upx;
		height: 50upx;
		min-height: 50upx;
		padding: 15upx 20upx;
		line-height: 50upx;
		background-color: #FFFFFF;
	}
	.feedback-uploader {
		padding: 22upx 20upx;
	}
    .feedback-submit {
    	background: #2fc25b;
    	color: #FFFFFF;
    	margin: 20upx;
    }
</style>
